[PHP] - Output buffer based progress bar

Posted by KPL on Stack Overflow See other posts from Stack Overflow or by KPL
Published on 2010-05-06T11:20:13Z Indexed on 2010/05/06 11:28 UTC
Read the original article Hit count: 273

Filed under:

Hello people,

I have been trying to get the following code working.

It's a progress bar trick which uses ob_get_clean() function.

Don't know why but this script just don't work!

Only the initial percent - 1% comes up and nothing after that.

<?php  
error_reporting(8191);  
function flush_buffers(){  
    @ob_end_flush();  
    @ob_flush();  
    @flush();  
    @ob_start();
} 
$ini    =   2;
echo '<script>document.getElementById(\'lpt\').style.width=\'1%\';</script><br>';  
for($i=1;$i<=100;$i++)  {
            $k=$ini-1;
            $str=str_replace("width=\'$k%\'","width=\'$i%\'",ob_get_clean());           
            $ini++;
            echo $str;
            flush_buffers();
}

?>

© Stack Overflow or respective owner

Related posts about php